/**
 * 
 */
package com.tunan.lsj.idgenerator;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 与环境有关的判断
 * 
 * @author czhcc
 *
 */
public class Environment
{
	public static final String ipaddress = "ipaddress";
	
	public static boolean isDebug()
	{
		return System.getProperty("debug") != null;
	}
	
	public static boolean isLinuxOS()
	{
		return System.getProperty("os.name").equals("Linux");
	}
	
	public static boolean isMSWindowsOS()
	{
		return System.getProperty("os.name").startsWith("Windows");
	}
	
	public static String getLocalHostIP()
	{
		try
		{
			return InetAddress.getLocalHost().getHostAddress();
		}
		catch(UnknownHostException e)
		{
			return "127.0.0.1";
		}
	}
	
	public static String getLocalHostname()
	{
		try
		{
			return InetAddress.getLocalHost().getHostName();
		}
		catch(UnknownHostException e)
		{
			return "localhost";
		}
	}
	
	public static boolean runOnAppServer()
	{
		return System.getProperty("rcp.run.local") == null;
	}
}
